/** 
  -- The Performance Driven Lime Project -- 

  A self adaptive tuple space for mobile agents and hosts by dynamic
  adapting tuple's replication policy.
  
  Copyright (C) 2008
  Xing Jiankuan, Pan Wenhui
  SAGroup of Tsinghua University

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received this copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
 */
package sagroup.dracots;

import java.util.HashSet;
import java.util.Set;

/**
 * Define system used tuple type.
 * @author Xing Jiankuan
 *
 */
public class SystemTupleType extends TupleType {
	
	private static final long serialVersionUID = -2918529026748378337L;

	private SystemTupleType(String typeName) {
		super(typeName);
		// do not use this constructor
	}

	public static Set systemTupleTypes = new HashSet();
	/**
	 * The type of tuples that defines other types and their replication policies
	 */
	public final static TupleType META = create("META");
	
	/**
	 * The type of tuples that defines other types' replication policies
	 */
	public final static TupleType REPLICATION_POLICY = create("REPLICATION_POLICY");
	
	/**
	 * The type of tuples used as command
	 */
	public final static TupleType COMMAND = create("COMMAND");
	
	/**
	 * The type of tuples used as published
	 */
	public final static TupleType PUBLISHED = create("PUBLISHED");
	
	/**
	 * For those tuples who are not assigned a type, they have this default type.
	 */
	public final static TupleType ANYTYPE = create("ANYTYPE");
	
	public static boolean isSystemTupleType(TupleType type) {
		if(systemTupleTypes.contains(type.getTypeName())) return true;
		else return false;
	}
	
	private static TupleType create(String typeName) {
		systemTupleTypes.add(typeName);
		return new TupleType(typeName);
	}
}
